/*
	File taken from GitHub user Lightczx (DGP-Studio/Snap.Hutao/issues/2446)
	That repository is licensed under MIT, thus assuming the same for this comment.
*/

syntax = "proto3";

message DiffManifest {
	repeated DiffFileInfo files = 1;
	repeated DeleteFile files_delete = 2;
}

message DiffFileInfo {
	string filename = 1; // Path to the file relative to the game directory
	int32 size = 2;      // Size of the entire file
	string hash = 3;     // md5 file hash AFTER patching
	repeated Patch patches = 4;
}

message Patch {
	string key = 1;	 // Game version, e.g. "5.5.0"
	PatchInfo info = 2;
}

message PatchInfo {
	// File hash on disk "[8 bytes -> hex]_[16 bytes -> hex]" an
	// URL suffix after getPatchBuild -> '.data.manifests.[N].diff_download.url_prefix'
	string patch_id = 1;
	string tag = 2;	 // Game version, e.g. "5.5.0" or "5.4.0" (when updating to "5.6.0"
	string build_id = 3;

	int64  patch_size = 4;
	string patch_name  = 5; // = "[8 bytes -> hex]" from 'id' above
	int64  patch_offset = 6;
	int64  patch_length = 7;

	string original_name = 8;
	int64  original_size = 9;
	string original_hash = 10; // md5 file hash BEFORE patching
}

message DeleteFile
{
	string key = 1;
	DeleteFiles info = 2;
}

message DeleteFiles
{
	repeated DeleteFileInfo list = 1;
}

message DeleteFileInfo
{
	string filename = 1;
	int64  size = 2;
	string hash = 3;
}
